<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="author" content="HuyTD" />
	<title>Untitled 3</title>
</head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="http://swfobject.googlecode.com/svn/trunk/swfobject/src/swfobject.js" type="text/javascript"></script>
<script type="text/javascript">
var socket;
var flashvars = false;
var params = {
  menu: "false",
  allowscriptaccess: "always"
};
var attributes = {
  id: "socketB",
  name: "socketB"
};

swfobject.embedSWF("asjs.swf", "socketB", "50", "25", "9.0.0","expressInstall.swf", flashvars, params, attributes, loadSuccess);

function loadSuccess() {
    socket = document.getElementById('socketB');
    $("ul").append("<li>Click Connect to start</li>");
}

function on_data_received(content) {
    $("#loading").hide();
    $("ul").append("<li><b>Received:</b> " + content + "</li>");
}

function connect() {
    $("#loading").show();
    socket.Create("localhost", 9050); 
    console.log("open");
}

function send() {
    socket.Send($("#txt").val());
    $("ul").append("<li><b>Send:</b> " + $("#txt").val() + "</li>");
}
</script>

<body>
<div id="socketB"></div><input type="button" onclick="connect()" value="Connect" /><br />
<input type="text" value="type something" id="txt" /><input type="button" onclick="send()" value="Send" />
<br />
<div style="display: none;" id="loading">Processing...</div>
<ul>
</ul>
</body>
</html>